#include "app_type.h"
#include "interfaces.h"

#if IFS_ADC_EN

#include "M45x_ADC.h"
#include "M451Series.h"

#define M45X_ADC_NUM				1

vsf_err_t m45x_adc_init(uint8_t index)
{

	CLK->CLKDIV0 = (CLK->CLKDIV0 & (~CLK_CLKDIV0_EADCDIV_Msk)) | (100 -1);
	CLK->APBCLK0 |= CLK_APBCLK0_EADCCKEN_Msk;

	return VSFERR_NONE;
}

vsf_err_t m45x_adc_fini(uint8_t index)
{
	if (index >= M45X_ADC_NUM)
		return VSFERR_NOT_SUPPORT;

	EADC->CTL &= ~EADC_CTL_ADCEN_Msk;
	CLK->APBCLK0 &= ~CLK_APBCLK0_EADCCKEN_Msk;

	return VSFERR_NONE;
}
vsf_err_t m45x_adc_config(uint8_t index, uint32_t clock_hz, uint8_t mode);
vsf_err_t m45x_adc_config_channel(uint8_t index, uint8_t channel,
									uint8_t cycles);
vsf_err_t m45x_adc_calibrate(uint8_t index, uint8_t channel);
uint32_t m45x_adc_get_max_value(uint8_t index);
vsf_err_t m45x_adc_start(uint8_t index, uint8_t channel);
vsf_err_t m45x_adc_isready(uint8_t index, uint8_t channel);
uint32_t m45x_adc_get(uint8_t index, uint8_t channel);




#endif

